<?php
/*
 * Created on 09.04.2007
 * @filesource: admin.schichtplan.html.php
 * @author: Nikolai Plath
 */


 defined( '_VALID_MOS' ) or die( 'Direct Access to this
      script is not allowed');
   class HTML_Schichtplan {
      function listItems ( $option, &$rows ) {
         $number = count($rows);
   echo '
      <script language="javascript" type="text/javascript">
         function submitbutton(pressbutton) {
           var form = document.adminForm;
           if (pressbutton == "cancel") {
              submitform( pressbutton );
              return;
           }
           submitform( pressbutton );
        }
     </script>
     <form action="index2.php" method="post"
           name="adminForm">
      <table cellpadding="4" cellspacing="0"
             border="0" width="100%" class="adminlist">
       <tr>
        <th width="20">
         <input type="checkbox" name="toggle"
                value="" onclick="checkAll('.$number.');"/>
        </th>
        <th align="left">Uhrzeit</th>
        <th align="left">Montag</th>
        <th align="left">Dienstag</th>
        <th align="left">Mittwoch</th>
        <th align="left">Donnerstag</th>
        <th align="left">Freitag</th>
        <th align="left">Samstag</th>
        <th align="left">Sonntatg</th>
        <th>Published</th>
       </tr>';
        $i = 0;
        foreach ($rows as $row) {
           $evenodd = $i % 2;
  echo '
      <tr class="row'.$evenodd.'">
       <td>
        <input type="checkbox" id="cb'.$i.'" name="cid[]"
               value="'.$row->id.'"
               onclick="isChecked(this.checked);" />
       </td>
      <td>
        <a href="#edit"
           onclick="return listItemTask(\'cb'.$i.'\',\'edit\')">
          '.$row->uhrzeit.'</a>
       </td>
       <td>'. getdjname($row->mo) .'</td>
       <td>'. getdjname($row->di).'</td>
       <td>'. getdjname($row->mi).'</td>
       <td>'. getdjname($row->do).'</td>
       <td>'. getdjname($row->fr).'</td>
       <td>'. getdjname($row->sa).'</td>
       <td>'. getdjname($row->so).'</td>
       <td align="center">';
           if ($row->published == "1") {
              echo "<img src='images/tick.png' "
                   ."border='0' />";
           } else {
              echo "<img src='images/publish_x.png' "
                   ."border='0' />";
           }
           echo "</td></tr>";
           $i++;
        }
  echo '
  		 </table>
      <input type="hidden" name="option"
             value="'.$option.'" />
      <input type="hidden" name="task" value="" />
      <input type="hidden" name="boxchecked" value="0" />
     </form>';
     }

  function edit( $option, &$row ) { ?>

  <script language="javascript" type="text/javascript">
        function submitbutton(pressbutton) {
           var form = document.adminForm;
           if (pressbutton == "cancel") {
              submitform( pressbutton );
              return;
           }
           submitform( pressbutton );
        }
     </script>
    <form action="index2.php" method="post"
        name="adminForm" id="adminForm" class="adminForm">
     <table border="0" cellpadding="3" cellspacing="0" class="adminlist">
      <tr>
       <th align="left">Uhrzeit</th>
        <th align="left">Montag</th>
        <th align="left">Dienstag</th>
        <th align="left">Mittwoch</th>
        <th align="left">Donnerstag</th>
        <th align="left">Freitag</th>
        <th align="left">Samstag</th>
        <th align="left">Sonntatg</th>
       </tr>
       <tr>
       <td>
        <input type="text" size="8" maxsize="20"
               name="uhrzeit" value="<?php echo $row->uhrzeit; ?>" />
      </td>

        <td><?php getcbuserfromid('mo', $row->mo); ?></td>
        <td><?php getcbuserfromid('di', $row->di); ?></td>
        <td><?php getcbuserfromid('mi', $row->mi); ?></td>
        <td><?php getcbuserfromid('do', $row->do); ?></td>
        <td><?php getcbuserfromid('fr', $row->fr); ?></td>
        <td><?php getcbuserfromid('sa', $row->sa); ?></td>
        <td><?php getcbuserfromid('so', $row->so); ?></td>
      </tr>
     </table>
     <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
    <input type="hidden" name="option" value="<?php echo $option; ?>" />
    <input type="hidden" name="task" value="" />
   </form>

<?php

/*
 * <form id="form1" name="form1" method="post" action="">
  <label>asdfg
  <select name="select">
    <option>qwe</option>
    <option selected="selected">qwewqw</option>
    <option>wwwww</option>
  </select>
  </label>
</form>
 */



 }

  }

function getcbuserfromid ( $dertag, $cbuserid )
{

	global $database;

	$query="SELECT * from #__comprofiler".
			"\n WHERE cb_hitradiostatus='DJ'";

	$database->setQuery($query);
	$cbusers=$database->loadObjectList();
 	echo '<select name="' . $dertag . '">';
    echo '<option value="0">Non Stop</option>';

	foreach ($cbusers as $cbuser)
	{
    echo '<option value="' . $cbuser->user_id . '"';

	if ($cbuser->user_id == $cbuserid)
	{
		echo ' selected="selected"';
	}

    echo '>' . $cbuser->cb_djname . '</option>';
	}
//    <option selected="selected">qwewqw</option>
  echo '</select>';

}

function getdjname ($djid)
{
	global $database;
	if ($djid == '0')
	{
		return "---";
	}
	$database->setQuery("SELECT cb_djname from #__comprofiler".
			"\n WHERE user_id='".$djid."'");
	return $database->loadResult();
}
?>
